package com.ljy.controller.admin;

import com.ljy.result.Result;
import com.qcloud.TXCloudUpload;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/admin/common")
public class CommonController {
    @Autowired
    TXCloudUpload txCloudUpload;

    @PostMapping("/upload")
    public Result upload(@RequestBody MultipartFile file) throws IOException {
        String url = txCloudUpload.Upload(file);
        return Result.success(url);
    }
}
